package bstsetcode.stanforduniversity18;

/**
 * @author noob
 * @version 1.0
 * @date 2021/3/15 20:48
 * 挂接两个链表
 */
public class _08_append {

    public  static ListNode  append(ListNode headA,ListNode headB){
        if (headA == null){
            return headB;
        }
        if(headB == null){
            return headA;
        }
        ListNode cur=headA;
        while (cur.next !=null){
            cur = cur.next;
        }
        cur.next = headB;
        return  headA;
    }

    public static void main(String[] args) {
        int[] nums1 = {1,2,3,4};
        ListNode headA = new ListNode(nums1);

        int[] nums2 = {5,6,7,8};
        ListNode headB = new ListNode(nums2);

        ListNode append = _08_append.append(headA, headB);
        System.out.println(append);

    }

}
